const http = require('http');


// 创建http应用服务的实例对象
let sever = http.createServer();

// 给服务实例sever绑定接收request的事件
sever.on("request", (req, res) => {
  console.log(`请求的地址是：${req.url}`);
  res.setHeader("Content-Type", "text/plain;charset=utf-8");
  res.write('666');
  res.write('你好,我是nodejs');
  res.write('this is my first nodejs API');
  res.end()
})

// 绑定监听的端口，开启服务
sever.listen(8080, '127.0.0.1', () => {
  console.log(`服务已启动！正在监听${8080}端口`);
})